package Object;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;

public class ObjectStreamDemo3 {
    public static void main(String [] args) throws IOException {
        Student02 stu1 = new Student02("苏子豪", 20, "男", "河南");
        Student02 stu2 = new Student02("贺东鹏", 21, "男", "安阳");
        Student02 stu3 = new Student02("苗毅诚", 21, "男", "洛阳");
        Student02 stu4 = new Student02("谢斌", 22, "男", "信阳");



        ArrayList<Student02> list = new ArrayList<Student02>();
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        list.add(stu4);

        ObjectOutputStream ois = new ObjectOutputStream(new FileOutputStream("code.txt"));
        ois.writeObject(list);
        ois.close();
    }
}
